package com.management.controller;


import com.management.controller.form.AddSeverityForm;
import com.management.controller.form.ChangeSeverityFrom;
import com.management.controller.form.GetALLSeverityFrom;
import com.management.controller.form.GetSeverityByNameForm;
import com.management.service.DefectSeverityService;
import com.management.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
@Api(tags = "严重程度相关")
@RestController
@RequestMapping("/defectSeverity")
public class DefectSeverityController {
    @Resource
    private DefectSeverityService defectSeverityService;

    /**
     * 分页获取所有严重程度
     * @param getALLSeverityFrom 分页参数
     * @return
     */
    @ApiOperation("分页获取所有严重程度")
    @PostMapping("getAllSeverity")
    public Result getAllSeverity(@RequestBody GetALLSeverityFrom getALLSeverityFrom){
       Result result= defectSeverityService.findAllSeverity(getALLSeverityFrom);
       return result;

    }

    /**
     * 新增严重程度
     * @param addSeverityForm 相关参数
     * @return
     */
    @ApiOperation("新增严重程度")
    @PostMapping("addSeverity")
    public Result addSeverity(@RequestBody AddSeverityForm addSeverityForm){
       Result result= defectSeverityService.addSeverity(addSeverityForm);
       return  result;
    }

    /**
     * 修改严重程度状态
     * @param severityId 严重程度ID
     * @return
     */
    @ApiOperation("修改严重程度状态")
    @GetMapping("closeSeverity")
    public Result closeSeverity(Integer severityId){
       Result result= defectSeverityService.changeSeverityState(severityId);
       return result;
    }

    /**
     * 修改严重程度前检查状态是否为启用
     * @param severityId 严重程度ID
     * @return
     */
    @ApiOperation("修改严重程度前检查状态是否为启用")
    @GetMapping("checkSeverity")
    public Result checkSeverity(Integer severityId){
       Result result= defectSeverityService.checkSeverity(severityId);
       return result;
    }

    /**
     * 修改严重程度
     * @param changeSeverityFrom 参数
     * @return
     */
    @ApiOperation("修改严重程度")
    @GetMapping("changeSeverity")
    public Result changeSeverity(ChangeSeverityFrom changeSeverityFrom){
       Result result= defectSeverityService.changeSeverity(changeSeverityFrom);
       return  result;
    }

    /**
     * 删除某个严重程度
     * @param severityId 严重程度ID
     * @return
     */
    @ApiOperation("删除某个严重程度")
    @GetMapping("delSeverity")
    public Result delSeverity(Integer severityId){
       Result result= defectSeverityService.delSeverity(severityId);
       return result;
    }

    /**
     * 模糊查询严重程度
     * @param getSeverityByNameForm 分页以及查询参数
     * @return
     */
    @ApiOperation("模糊查询严重程度")
    @PostMapping("selByName")
    public Result selByName(@RequestBody GetSeverityByNameForm getSeverityByNameForm){
       Result result= defectSeverityService.selByName(getSeverityByNameForm);
       return result;
    }

    /**
     * 不分页获取所有严重程度
     * @return
     */
    @ApiOperation("不分页获取所有严重程度")
    @GetMapping("getAllSeveritys")
    public Result getAllSeveritys(){
        Result result=defectSeverityService.getAllSeveritys();
        return result;
    }
}

